//package com.jiegui.modules.common.interceptor;
//
//
//import com.jiegui.common.exception.user.RRException;
//import com.jiegui.common.utils.Constant;
//import com.jiegui.common.utils.StringUtils;
//import com.jiegui.wx.domain.WechatUser;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//import org.springframework.web.method.HandlerMethod;
//import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * 代理商登入拦截
// *
// * @author xiaoyi
// */
//@Slf4j
//@Component
//public class ManageLoginInterceptor extends HandlerInterceptorAdapter {
//
//    @Value("${jiegui.AccessAddress}")
//    String accessAddress;
//
////	@Value("${spring.profiles.active}")
////	private String state;
////
////	private String redirectPath;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//
//        Thread.currentThread().setName("UPF2.0-" + Thread.currentThread().getId() + "-" + System.currentTimeMillis());
//        if (handler instanceof HandlerMethod) {
//            String path = request.getRequestURI();
//            WechatUser user = (WechatUser) request.getSession().getAttribute(Constant.LOGIN_SESSION_AUTH);
//            if (user == null) {
//                //不拦截特定请求
//                if (path.indexOf("/getOpenId") != -1 || path.indexOf("/error") != -1 || path.indexOf("getCode") != -1 || path.indexOf("logout") != -1) {
//                    return true;
//                } else {
//                    throw new RRException("请先授权", 305);
//                }
//            } else {
//               if(StringUtils.isEmpty(user.getPhone())){
//                   if(path.indexOf("/sendVerifyCode") != -1 || path.indexOf("/login") != -1){
//                       return true;
//                   }
//                   throw new RRException("请先登入", 304);
//               }
//            }
//
//        }
//
//        return true;
//    }
//
//}
